<?php

declare(strict_types=1);

namespace app\validate\org;

use think\Validate;

class OrgAuditValidate extends Validate
{
    protected $rule = [
        'id' => 'require|integer|gt:0',
        'type' => 'require|in:company,individual',
        'remark' => 'max:255',
    ];

    protected $message = [
        'id.require' => '组织ID不能为空',
        'id.integer' => '组织ID格式不正确',
        'id.gt' => '组织ID格式不正确',
        'type.require' => '认证类型不能为空',
        'type.in' => '认证类型不支持',
        'remark.max' => '备注不能超过255个字符',
    ];

    protected $scene = [
        'approve' => ['id', 'type', 'remark'],
        'reject' => ['id', 'type', 'remark'],
    ];

    protected function sceneReject(): self
    {
        return $this->only(['id', 'type', 'remark'])
            ->append('remark', 'require');
    }
}
